
#include "SymbolTable.h"

namespace mjc {

	SymbolTable::SymbolTable()
		:scope(),
		intType(Type::K_INT),
		charType(Type::K_CHAR),
		nullType(Type::K_CLASS),
		noType(Type::K_NONE),
		chrObject(Object::K_METHOD, L"chr", charType),
		ordObject(Object::K_METHOD, L"ord", intType),
		lenObject(Object::K_METHOD, L"len", intType),
		noObject(Object::K_VARIABLE, L"???", noType)
	{
		scope.AddObject(Object(Object::K_TYPE, L"int", intType));
		scope.AddObject(Object(Object::K_TYPE, L"char", charType));
		scope.AddObject(Object(Object::K_CONSTANT, L"null", nullType));

		chrObject.GetMethodData().SetNParameters(1);
		chrObject.GetMethodData().AddLocal(Object(Object::K_VARIABLE, L"i", intType));
		scope.AddObject(chrObject);

		ordObject.GetMethodData().SetNParameters(1);
		ordObject.GetMethodData().AddLocal(Object(Object::K_VARIABLE, L"ch", charType));
		scope.AddObject(ordObject);

		lenObject.GetMethodData().SetNParameters(1);
		lenObject.GetMethodData().AddLocal(Object(Object::K_VARIABLE, L"a", Type(Type::ArrayData(noType))));
		scope.AddObject(lenObject);
	}
}